#include<iostream>
#include<vector>
using namespace std;

int search(vector<int>& nums,int target){
    //朴素二分查找
    int left = 0, right = nums.size() - 1;
    int mid = 0;

    while(left<=right){
        //获取中间值
        //两种写法
        mid = left + (right - left) / 2;
        //mid = left + (right - left + 1) / 2;

        if(nums[mid]<target){
            left = mid + 1;
        }
        else if(nums[mid]>target){
            right = mid - 1;
        }
        else{
            return mid;
        }
    }

    return -1;
}

int main(){
    int target=0;
    vector<int> nums = {};

    int ret = search(nums, target);
    cout << ret;
    return 0;
}